package cate.game.fight.hero.dyn;

import cate.common.table.dynins.DynHeroLevelRow;
import cate.common.table.dynins.DynSpiceRow;
import cate.common.table.item.hero.row.HeroBaseRow;
import cate.common.util.XT;
import cate.game.role.bag.hero.Hero;
import cate.game.role.bag.spice.Spice;

import java.util.List;

public class DynSpiceUtil extends DynItemUtil {

	@Override
	public void setUp(Hero hero, HeroBaseRow heroTpl, DynHeroLevelRow itemTpl) {
		if (itemTpl.spiceCode <= 0) {
			return;
		}
		DynSpiceRow spiceRow = ctx.dynInsExcel().spice.get(itemTpl.runeCode);
		if (spiceRow == null) {
			return;
		}
		List<DynSpiceRow.Config> configs= spiceRow.getConfig(heroTpl.job);
		if (XT.isBlank(configs)) {
			return;
		}
		for (DynSpiceRow.Config config : configs) {
			Spice spice = new Spice(null, config.tid, 1);
			spice.level = config.level;
			hero.exPart.addAttr(spice.getPowerAttr(ctx));
		}
	}
}
